<?php
@header('Content-Type: text/html; charset=UTF-8');
if ($conf['active_download'] == 1) {
    $rs=$DB->query("SELECT * FROM authguao_program WHERE active=1 order by id desc");
} else {
    $rs=$DB->query("SELECT * FROM authguao_program WHERE 1 order by id desc");
}
while($res = $DB->fetch($rs))
{
    $select .= '<option value="'.$res['id'].'">'.$res['name'].'</option>';
}
$Market_name=addslashes($conf['Market_name'])?addslashes($conf['Market_name']):'平台商城';
if ($userrow['power'] == 3) {
    $power_name = '全能管理员';
} else if ($userrow['power'] == 2) {
    $power_name = '超级管理员';
} else if ($userrow['power'] == 1) {
    $power_name = '授权商';
} else {
    $power_name = '普通用户';
}
if($userrow['power']==3){
    $type = '0,2,3';
}elseif($userrow['power']==2){
    $type = '0,2,4';
    $types = '6';
}elseif($userrow['power']==1){
    $type = '0,2,5';
    $types = '7';
}else{
    $type = '0,1';
}
$msgcounts=$DB->count("SELECT count(*) FROM authguao_message WHERE type IN ($type) AND active=1");
if($userrow['power']==0 || $userrow['power']==3){
    $msgcount=$msgcounts;
}else{
    $msgcountss=$DB->count("SELECT count(*) FROM authguao_message WHERE type='{$types}' AND proid='{$userrow['proid']}' AND active=1");
    $msgcount=$msgcounts+$msgcountss;
}
$msgread = explode(',',$userrow['msgread']);
$rs=$DB->query("SELECT * FROM authguao_message WHERE type IN ($type) AND active=1 ORDER BY id DESC");
$rss=$DB->query("SELECT * FROM authguao_message WHERE type='{$types}' AND proid='{$userrow['proid']}' AND active=1 ORDER BY id DESC");
$msgrow=array();
$msgrows=array();
while($res = $DB->fetch($rs)){
    if(in_array($res['id'],$msgread))$res['read']=true;
    else $res['read']=false;
    $msgrow[]=$res;
}
while($ress = $DB->fetch($rss)){
    if(in_array($ress['id'],$msgread))$ress['read']=true;
    else $ress['read']=false;
    $msgrows[]=$ress;
}
if($conf['admin_qq']){
    $admin_qq=$conf['admin_qq'];
}else{
    $admin_qq=$conf['kfqq'];
}
$gdcount=$DB->count("SELECT count(*) FROM authguao_workorder WHERE uid='{$userrow['uid']}' AND status=1");
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8"/>
    <title><?php echo $title;?> [平台用户的后台]</title>
    <meta name="keywords" content="<?= $conf['keywords'] ?>">
    <meta name="description" content="<?= $conf['description'] ?>">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta content="A fully featured admin theme which can be used to build CRM, CMS, etc." name="description"/>
    <meta content="Coderthemes" name="author"/>
    <!-- App favicon -->
    <link rel="shortcut icon" href="../assets/favicon.ico" type="image/x-icon"/>
    <!-- third party css -->
    <link href="../assets/css/vendor/jquery-jvectormap-1.2.2.css" rel="stylesheet" type="text/css"/>
    <link rel="stylesheet" type="text/css" href="../assets/layui/css/layui.css"/>
    <!-- third party css end -->
    <!-- App css -->
    <link href="../assets/css/icons.min.css" rel="stylesheet" type="text/css"/>
    <link href="../assets/css/app.min.css" rel="stylesheet" type="text/css"/>
</head>
<style>
    .card-title {font-weight: 300;};
</style>
<body>
<!-- Begin page -->
<div class="wrapper">
    <div class="left-side-menu" style="z-index: 10">
        <div class="slimscroll-menu" id="left-side-menu-container">
            <!-- LOGO -->
            <!--- Sidemenu -->
            <ul class="metismenu side-nav">
                <li class="side-nav-title side-nav-item" style="font-size: 2em;color: white;font-weight: 300">用户管理后台
                </li>
                <li class="side-nav-item">
                    <a href="index.php" class="side-nav-link">
                        <i class="layui-icon layui-icon-home"></i>
                        <span> 用户首页 </span>
                    </a>
                </li>
                <li class="side-nav-item">
                    <a href="javascript: void(0);" class="side-nav-link">
                        <i class="layui-icon layui-icon-rmb"></i>
                        <span> 我的钱包 </span>
                        <span class="menu-arrow"></span>
                    </a>
                    <ul class="side-nav-second-level" aria-expanded="false">
                        <li><a href="recharge.php">在线充值</a><li>
                        <?php if($conf['user_jiakuank_open']==1){?><li><a href="jkklist.php">生成加款卡</a><li><?php }?>
                        <?php if($conf['user_tixian']==1){?><li><a href="tixian.php">余额提现</a><li><?php }?>
                        <?php if($conf['user_toMoney_open']==1){?><li><a href="toMoney.php">余额转换</a><li><?php }?>
                        <?php if($conf['user_zzMoney_open']==1){?><li><a href="zzMoney.php">余额转账</a><li><?php }?>
                        <li><a href="record.php">收支明细</a><li>
                    </ul>
                </li>
                <?php if($conf['adver_open']==1){?>
                <li class="side-nav-item">
                    <a href="javascript: void(0);" class="side-nav-link">
                        <i class="layui-icon layui-icon-notice"></i>
                        <span> 广告管理 </span>
                        <span class="menu-arrow"></span>
                    </a>
                    <ul class="side-nav-second-level" aria-expanded="false">
                        <li><a href="adverlist.php">广告列表</a><li>
                        <?php if($conf['adver_buy_open']==1){?><li><a href="adver.php">购买广告位</a></li><?php }?>
                    </ul>
                </li>
                <?php }?>
                <?php if($conf['Market_open']==1){?>
                <li class="side-nav-item">
                    <a href="javascript: void(0);" class="side-nav-link">
                        <i class="layui-icon layui-icon-cart"></i>
                        <span> <?php echo $Market_name?> </span>
                        <span class="menu-arrow"></span>
                    </a>
                    <ul class="side-nav-second-level" aria-expanded="false">
                        <li><a href="shop.php?type=1">模板类商品</a><li>
                        <li><a href="shop.php?type=2">插件类商品</a><li>
                        <li><a href="shop.php?type=3">其他类商品</a><li>
                        <li><a href="shop_log.php">已购商品</a><li>
                    </ul>
                </li>
                <li class="side-nav-item">
                    <a href="addshop.php" class="side-nav-link">
                         <i class="layui-icon layui-icon-upload"></i>
                         <span> 商品管理 </span>
                    </a>
                </li>
                <?php } ?>
                <li class="side-nav-item">
                    <a href="javascript:downfile();" class="side-nav-link">
                        <i class="layui-icon layui-icon-download-circle"></i>
                        <span> 下载源码 </span>
                    </a>
                </li>
                <li class="side-nav-item">
                    <a href="workorder.php" class="side-nav-link">
                        <i class="layui-icon layui-icon-survey"></i>
                        <span> 我的工单 <?php echo ($gdcount == 0 ? '' : '<span class="layui-badge layui-bg-red">' . $gdcount . '</span>') ?></span>
                    </a>
                </li>
                <?php if ($conf['chat_open'] == 1) { ?>
                <li class="side-nav-item">
                    <a href="chat.php" class="side-nav-link">
                        <i class="layui-icon layui-icon-dialogue"></i>
                        <span> 聊天交友 </span>
                    </a>
                </li>
                <?php }?>
                <?php if($conf['invite_rebate_open']==1){?>
                <li class="side-nav-item">
                    <a href="invite.php" class="side-nav-link">
                        <i class="layui-icon layui-icon-gift"></i>
                        <span> 邀请奖励 </span>
                    </a>
                </li>
                <?php }elseif($conf['guess_open']==1){?>
                <li class="side-nav-item">
                    <a href="guesslist.php" class="side-nav-link">
                        <i class="layui-icon layui-icon-gift"></i>
                        <span> 娱乐竞猜 </span>
                    </a>
                </li>
                <?php }?>
                <?php if($conf['cloud_api_open']==1 && $userrow['power']>0){?>
                <li class="side-nav-item">
                    <a href="key.php" class="side-nav-link">
                        <i class="layui-icon layui-icon-link"></i>
                        <span> 云端对接 </span>
                    </a>
                </li>
                <?php }?>
                <li class="side-nav-item">
                    <a href="login.php?logout" class="side-nav-link">
                        <i class="layui-icon layui-icon-logout"></i>
                        <span> 退出登陆 </span>
                    </a>
                </li>
            </ul>
        </div>
        <!-- Sidebar -left -->
    </div>
    <!-- Left Sidebar End -->
    <div class="content-page">
        <div class="content">
            <!-- Topbar Start -->
            <div class="navbar-custom">
                <ul class="list-unstyled topbar-right-menu float-right mb-0">
                    <li class="dropdown notification-list">
                        <a class="nav-link dropdown-toggle arrow-none" data-toggle="dropdown" href="#" role="button"
                           aria-haspopup="false" aria-expanded="false">
                            <i class="layui-icon layui-icon-email noti-icon"></i>
                            <?php if ($notice_user['code'] == 1){ ?>
                            <span class="noti-icon-badge">
                            <?php } ?>
                        </a>
                        <div class="dropdown-menu dropdown-menu-right dropdown-menu-animated dropdown-lg">

                            <!-- item-->
                            <div class="dropdown-item noti-title">
                                <h5 class="m-0">
                                     <span class="float-right">
                                         <a href="http://wpa.qq.com/msgrd?v=3&uin=<?php echo $admin_qq ?>&site=qq&menu=yes" target="_blank" class="text-dark">
                                                    <small>联系客服</small>
                                                </a>
                                            </span>
                                    官方通知
                                </h5>
                            </div>

                            <div class="slimscroll" style="max-height: 230px;">
                                <!-- item-->
                                <?php foreach($msgrow as $msgrows){ ?>
                                    <a href="index.php?act=notification&id=<?php echo $msgrows['id'] ?>" class="dropdown-item notify-item">
                                        <div class="notify-icon bg-primary">
                                            <i class="mdi mdi-comment-account-outline"></i>
                                        </div>
                                        <p class="notify-details"><?php echo $msgrows['title'] ?>
                                            <small class="text-muted"><?php echo $msgrows['addtime'] ?></small>
                                        </p>
                                    </a>
                                <?php } ?>
                                <?php if($userrow['power']>0 && $userrow['power']<3){?>
                                <?php foreach($msgrows as $msgrows){ ?>
                                    <a href="index.php?act=notification&id=<?php echo $msgrows['id'] ?>" class="dropdown-item notify-item">
                                        <div class="notify-icon bg-primary">
                                            <i class="mdi mdi-comment-account-outline"></i>
                                        </div>
                                        <p class="notify-details"><?php echo $msgrows['title'] ?>
                                            <small class="text-muted"><?php echo $msgrows['addtime'] ?></small>
                                        </p>
                                    </a>
                                <?php }} ?>
                            </div>
                            <!-- All-->
                        </div>
                    </li>
                    <li class="dropdown notification-list">
                        <a class="nav-link dropdown-toggle nav-user arrow-none mr-0" data-toggle="dropdown" href="#" role="button" aria-haspopup="false" aria-expanded="false">
                            <span class="account-user-avatar">
                                <img src="//q4.qlogo.cn/headimg_dl?dst_uin=<?php echo $userrow['qq'];?>&spec=640" alt="user-image" class="rounded-circle bg-warning" style="border: solid 2px #ccc">
                            </span>
                            <span>
                                <span class="account-user-name">用户名：<?php echo $userrow['user']?></span>
                                <span class="account-position">当前权限：<?php echo $power_name?></span>
                            </span>
                        </a>
                        <div class="dropdown-menu dropdown-menu-right dropdown-menu-animated topbar-dropdown-menu profile-dropdown">
                            <!-- item-->
                            <div class=" dropdown-header noti-title">
                                <h6 class="text-overflow m-0">快捷导航</h6>
                            </div>
                            <!-- item-->
                            <a href="http://wpa.qq.com/msgrd?v=3&uin=<?php echo $admin_qq ?>&site=qq&menu=yes" target="_blank" class="dropdown-item notify-item">
                                <i class="layui-icon layui-icon-chat mr-1"></i>
                                <span>联系官方</span>
                            </a>
                            <!-- item-->
                            <a href="../" target="_blank" class="dropdown-item notify-item">
                                <i class="layui-icon layui-icon-home mr-1"></i>
                                <span>前往首页</span>
                            </a>
                            <a href="set.php?mod=row" class="dropdown-item notify-item">
                                <i class="layui-icon layui-icon-set mr-1"></i>
                                <span>信息编辑</span>
                            </a>
                            <!-- item-->
                            <a href="login.php?logout" class="dropdown-item notify-item">
                                <i class="layui-icon layui-icon-logout mr-1"></i>
                                <span>注销账号</span>
                            </a>
                        </div>
                    </li>
                </ul>
                <button class="button-menu-mobile open-left disable-btn">
                    <i class="layui-icon layui-icon-spread-left"></i>
                </button>
                <div class="app-search">
                    <form>
                        <div class="input-group">
                            <input type="text" class="form-control" id="dw" placeholder="请输入需要搜索的内容">
                            <span class="layui-icon layui-icon-search"></span>
                            <div class="input-group-append">
                                <button class="btn btn-primary" type="button" onclick="window.open('https://www.baidu.com/s?ie=UTF-8&wd='+$('#dw').val())">百度一下</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
            <!-- end Topbar -->
            <!-- start page title -->
            <div class="row" style="width: 98%;margin: auto">
                <div class="col-12">
                    <!-- start page title -->
                    <div class="row">
                        <div class="col-12">
                            <div class="page-title-box">
                                <div class="page-title-right">
                                    <ol class="breadcrumb m-0">
                                        <li class="breadcrumb-item"><a href="index.php">首页</a></li>
                                        <li class="breadcrumb-item active"><?php echo $title ?></li>
                                    </ol>
                                </div>
                                <h4 class="page-title" style="font-weight: 400"><?php echo $title ?></h4>
                            </div>
                        </div>
                    </div>
                    <!-- end page title -->
                </div>
            </div>
            <!-- end page title -->
            <style>
                .note-popover {
                    display: none
                }
                .note-toolbar {
                    z-index: 9 !important;
                }
                .panel-heading {
                    border-bottom: 1px solid #ccc;
                }
            </style>